<?php
namespace app\banner\validate;
use think\Validate;
class Banner extends Validate {
    //验证字段
    protected $rule = [
        'id' => ['require','number'],
        'picture' => ['require'],
        'creater' => ['require'],
        'updater' => ['require'],
        'status' => ['require'],
        'sort' => ['require'],
        'category_id' => ['require'],
    ];
    //返回消息
    protected $message = [
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
        'picture.require' => '图片必须',
        'creater.require' => '创建者必须',
        'updater.require' => '更新者必须',
        'status.require' => '状态值必须',
        'sort.require' => '排序值必须',
        'category_id.require' => '分类id必须',
    ];

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['id','picture','creater','updater','status','sort','category_id']);
    }

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['picture','creater','updater','status','sort','category_id']);
    }

    public function  sceneAdd(){
        return $this->only(['category_id','picture','sort']);
    }

    public function  sceneEdit(){
        return $this->only(['category_id','picture','id','sort']);
    }
}
